<template>
  <div class="bus-passenger-flow-statistics">
    <nanning-screen-border-box :bgImg="bgImg">
      <screen-title>公交客流统计</screen-title>
      <div class="bus-passenger-flow-statistics-content" v-if="!loadingState && yData.length > 0">
        <div class="bus-num">
          <div>
            <span>40,037,992</span>
            <span>公交总人次</span>
          </div>
        </div>
        <div class="bus-echarts">
          <screen-chart @initCb="initChart"></screen-chart>
        </div>
      </div>
      <div class="bus-passenger-flow-statistics-content" v-else-if="loadingState && yData.length === 0">
        <screen-loading>
          <div class="loading-tip">加载中，请稍后...</div>
        </screen-loading>
      </div>
      <div class="bus-passenger-flow-statistics-content" v-else>
        <div class="no-data">
          <div class="no-data-img">
            <img :src="noData" alt="无数据" />
          </div>
        </div>
      </div>
    </nanning-screen-border-box>
  </div>
</template>

<script lang="ts">
import { getAvaChartOption } from './option'
import { Component, Vue } from 'vue-property-decorator'
@Component({
  name: 'bus-passenger-flow-statistics'
})
export default class BusPassengerFlowStatistics extends Vue {
  private bgImg: string = require('assets/images/box-border-1.png')

  private noData: string = require('assets/images/no-data.png')

  private avaChart: any = null

  private loadingState = false

  private xData: any = ['9:00', '10:00', '11:00', '12:00', '13:00', '14:00']

  private yData: any = [22, 33, 300, 100, 89, 33]

  private initChart(chart: any): void {
    chart.clear()
    this.avaChart = chart
    // chart.showLoading({
    //   text: '加载中',
    //   color: 'rgba(1, 178, 255, 0.9)',
    //   textColor: 'rgba(255, 255, 255, 0.7)',
    //   maskColor: 'rgba(255, 255, 255, 0)',
    //   zlevel: 0
    // })
    setTimeout(() => {
      // chart.hideLoading()
      this.avaChart.setOption(getAvaChartOption(this.xData, this.yData))
    }, 300)
  }
}
</script>

<style lang="scss" scoped>
.bus-passenger-flow-statistics {
  width: 100%;
  height: calc(46.81% - 10px);
  margin-bottom: 10px;
  &-content {
    box-sizing: border-box;
    height: calc(100% - 50px);
    .bus-num {
      box-sizing: border-box;
      width: 418px;
      height: 124px;
      background: url('../../../../assets/images/bus-bac.png') no-repeat center;
      background-size: 100% 100%;
      margin: auto;
      padding: 30px 0px 36px 0;
      div {
        box-sizing: border-box;
        width: calc(100% - 159px);
        margin-left: 159px;
        border-left: 1px solid #62a2cd;
        border-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.1), #23b7cb) 1 10;
        padding-left: 30px;
        span:nth-child(1) {
          display: block;
          color: #ffffff;
          font-size: 30px;
          font-family: 'PingFang Simple Bold';
          text-align: left;
        }
        span:nth-child(2) {
          display: block;
          font-size: 14px;
          color: rgba(255, 255, 255, 0.76);
          font-family: 'PingFang Regular';
          text-align: left;
        }
      }
    }
    .bus-echarts {
      box-sizing: border-box;
      width: 100%;
      height: calc(100% - 124px);
    }
    .loading-tip {
      font-family: 'PingFang Regular';
      color: #fff;
      font-size: 16px;
    }
    .no-data {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: rgba(255, 255, 255, 0.8);
      font-size: 18px;
      &-img {
        width: 249px;
        height: 172px;
      }
    }
  }
}
</style>
